<{include file="public/header" title="会员中心"/}>
</head>
<body>
<header>
    <div>
        <a href="javascript:history.back();"><i class="icon-fanhui icon iconfont"></i></a>
    </div>
    <div>
        添加地址
    </div>
    <div></div>
</header>
<div class="main vip">

    <div class="tabs">
        <a href="<{:url('User/user')}>">我的订单</a>
        <a href="<{:url('Address/address')}>" class="active">收货地址</a>
    </div>

    <div class="tabContent">
        <div class="addNewAddr">
            <!--<div class="tip">-->
            <!--您已保存了2个常用地址，最多可以保存5个-->
            <!--</div>-->
            <form action="<{:url('address/addressEdit')}>" method="post">
				<input type="hidden" name="id" value="<{$id}>">
                <div class="adr">
						<span class="takeP">
							<label for="">收货人：</label>
							<span>
								<input type="text" id="name" value="<{$name}>" name="name">
							</span>
						</span>
                    <span class="tel">
							<label for="">电话：</label>
							<span>
								<input type="number" id="tel" value="<{$tel}>" name="tel">
							</span>
						</span>
                    <span class="provi">
							<label for="">省份：</label>
							<span>
								<select name="sheng" class="sheng">
									<{foreach $shengs as $v}>
									<option value="<{$v['id']}>" <{$v['id']==$sheng?'selected':''}> ><{$v['name']}> </option>
									<{/foreach}>
								</select>
							</span>
						</span>
                    <span class="city">
							<label for="">地市：</label>
							<span>
								<select name="city" class="citys">
									<option value="<{$city}>"><{$cname}></option>
								</select>

							</span>
						</span>
                    <span class="county">
							<label for="">区县：</label>
							<span>
								<select name="quyu" class="quyu">
									<option value="<{$quyu}>"><{$qname}></option>
								</select>
							</span>

						</span>
                    <span class="otherAddInfo">
							<label for="">详细地址：</label>
							<span>
								<input type="text" id="address" value="<{$address}>" name="address">
							</span>
						</span>
                </div>
				<button  class="addAddr">保存</button>
            </form>
        </div>
    </div>
</div>
<footer>
    <{include file="public/footer"/}>
</footer>
</body>
</html>
<script>
    $(function () {
        $('.sheng').change(function () {
            var sheng = $('.sheng').val();
            $.ajax({
                type: 'post',
                url: '<{:url("Address/addressSheng")}>',
                data: {sheng:sheng},
                dataType:'json',
                success: function (d) {
                    console.log(d);
                    $('.citys').empty();
                    $.each(d,function(i,o){
                        var name = o.name;
                        var html = '<option value="'+o.id+'">'+name+'</option>';
                        $('.citys').append(html);
                    });
                    $(".citys").trigger("change");
                }
            });
        });
    })

    $('.citys').change(function () {
        var city = $('.citys').val();
        $.ajax({
            type: 'post',
            url: '<{:url("Address/addressCity")}>',
            data: {city:city},
            dataType:'json',
            success: function (d) {
                $('.quyu').empty();
                $.each(d,function(i,o){
                    var name = o.name;
                    var html = '<option value="'+o.id+'">'+name+'</option>';
                    $('.quyu').append(html);
                });

            }
        });
    });









</script>